<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Relations\BelongsTo;

class LearnVideoSection extends BaseModel
{

    protected $guarded = [];

    protected $appends = ['duration'];

    public function getDurationAttribute()
    {
        if (!$this->total_second) return '';

        return fromatDuration($this->total_second);
    }

    public function learnVideo(): BelongsTo
    {
        return $this->belongsTo(LearnVideo::class, 'learn_video_id');
    }

    public function learnVideoChapter(): BelongsTo
    {
        return $this->belongsTo(LearnVideoChapter::class, 'learn_video_chapter_id');
    }
}
